//trung binh cong
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 100
void nhapmang(int a[],int n){
	printf("nhap mang: ");
	for(int i=0;i<n;i++){
		printf("\n\ta[%d]= ",i);
		scanf("%d",&a[i]);	
	}
}
void xuatmang(int a[], int n){
	printf("\nmang vua nhap vao la: ");
	for(int i=0; i<n; i++){
		printf("\t%d",a[i]);
	}
}
int tinhtong(int a[], int n)
{
 int i, sum=0;
 for(i=0; i<n; i++)
 sum=sum+a[i];
 return sum;
}
float trungbinh(float sum, int n)
{
 float trungbinh= (float)sum/n;
 return trungbinh;
}

int main(){
	int a[MAX];
	int n;
	printf("\nnhap vao so phan tu cua mang: ");
	scanf("%d",&n);
	nhapmang(a,n);
	xuatmang(a,n);
	int sum = tinhtong(a,n);
	printf("\ntong cac phan tu trong mang: %d",sum);
	printf("\ntrung binh cong cua cac phan tu mang la: %0.2f",trungbinh(sum,n));
	getch();
} 
